package com.zhentao.recharge.feign;

import com.zhentao.pojo.Result;
import com.zhentao.pojo.TOrder;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * 充值服务Feign客户端接口
 * 
 * @author zhentao
 * @since 2024-08-13
 */
@FeignClient(name = "zk-recharge-service", fallback = RechargeFeignFallback.class)
public interface RechargeFeignClient {

    /**
     * 分页查询门诊充值记录
     * 
     * @param page 页码
     * @param pageSize 每页大小
     * @param patientId 患者ID
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @param bizType 业务类型
     * @return 充值记录分页数据
     */
    @GetMapping("/recharge/list")
    Result<Object> getRechargeRecords(
            @RequestParam("page") Integer page,
            @RequestParam("pageSize") Integer pageSize,
            @RequestParam(value = "patientId", required = false) Long patientId,
            @RequestParam(value = "startDate", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
            @RequestParam(value = "endDate", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
            @RequestParam(value = "bizType", required = false) String bizType);

    /**
     * 根据患者ID查询充值记录
     * 
     * @param patientId 患者ID
     * @return 充值记录列表
     */
    @GetMapping("/recharge/patient/{patientId}")
    Result<List<TOrder>> getRechargeRecordsByPatientId(@PathVariable("patientId") Long patientId);

    /**
     * 根据订单ID查询充值记录详情
     * 
     * @param orderId 订单ID
     * @return 充值记录详情
     */
    @GetMapping("/recharge/detail/{orderId}")
    Result<TOrder> getRechargeDetail(@PathVariable("orderId") Integer orderId);

    /**
     * 新增充值记录
     * 
     * @param order 充值记录
     * @return 操作结果
     */
    @PostMapping("/recharge/add")
    Result<Boolean> addRechargeRecord(@RequestBody TOrder order);

    /**
     * 更新充值记录
     * 
     * @param order 充值记录
     * @return 操作结果
     */
    @PutMapping("/recharge/update")
    Result<Boolean> updateRechargeRecord(@RequestBody TOrder order);

    /**
     * 删除充值记录
     * 
     * @param orderId 订单ID
     * @return 操作结果
     */
    @DeleteMapping("/recharge/delete/{orderId}")
    Result<Boolean> deleteRechargeRecord(@PathVariable("orderId") Integer orderId);

    /**
     * 健康检查接口
     * 
     * @return 服务状态
     */
    @GetMapping("/recharge/health")
    Result<String> health();
} 